<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>时间问候</title>
</head>
<body>
    <button>你好你好，我现在是几点</button>
    <div id="come">来吧</div>
    <script>
        var btn = document.querySelector('button');
        var text = document.getElementById('come');
        btn.onclick = function () {
            var date = new Date();
            h = date.getHours();
            if(h<12){
                text.innerText = '早上好';
            }
            else if(h<18){
                text.innerText = '下午好';
            }
            else{
                text.innerText = '晚上好';
            }
        }
    </script>
</body>
</html>